using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Data;
using THSERP.BusinessEntities;
using THSERP.BaseProvider;
using THSLib;

namespace THSERP.Modules.Report
{
    public partial class ARRP002InvoiceItemsGridControl : THSGridControl
    {
        protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView()
        {
            base.InitializeGridView();
            DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView();
            gridView.OptionsView.ShowFooter = true;
            gridView.OptionsCustomization.AllowFilter = true;
            gridView.OptionsView.ShowAutoFilterRow = true;

            DevExpress.XtraGrid.Columns.GridColumn colQty = gridView.Columns["ARInvoiceItemProductQty"];
            colQty.SummaryItem.FieldName = "ARInvoiceItemProductQty";
            colQty.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colQty.SummaryItem.DisplayFormat = "{0:n2}";

            DevExpress.XtraGrid.Columns.GridColumn colPrice = gridView.Columns["ARInvoiceItemNetAmount"];
            colPrice.SummaryItem.FieldName = "ARInvoiceItemNetAmount";
            colPrice.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colPrice.SummaryItem.DisplayFormat = "{0:n2}";

            DevExpress.XtraGrid.Columns.GridColumn colCost = gridView.Columns["ARInvoiceItemTotalCost"];
            colCost.SummaryItem.FieldName = "ARInvoiceItemTotalCost";
            colCost.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colCost.SummaryItem.DisplayFormat = "{0:n2}";
            //int visibleIndex =0;
            //foreach (DevExpress.XtraGrid.Columns.GridColumn column in gridView.Columns)
            //{
            //    if (column.FieldName != "ARInvoiceItemProductAttribute")
            //    {
            //        column.VisibleIndex = visibleIndex;
            //        visibleIndex++;
            //    }
            //}
           
            return gridView;
        }

        protected override void AddColumnsToGridView(string strTableName, DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
            base.AddColumnsToGridView(strTableName, gridView);
            //DevExpress.XtraGrid.Columns.GridColumn colSupplierName = new DevExpress.XtraGrid.Columns.GridColumn();
            //colSupplierName.FieldName = "ARInvoiceItemSupplierName";
            //colSupplierName.Caption = "Supplier";
            //colSupplierName.OptionsColumn.AllowEdit = false;
            //gridView.Columns.Add(colSupplierName);
        }
    }
}
